import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:ls_work/viewmodel/medecine/medical_prescription_list_view_model.dart';
import 'package:ls_work/widgets/dotted_line.dart';

import '../medical_prescription_detail_page.dart';
class MedicalPrescriptionFragment extends BaseStatefulMvvmWidget{
  @override
  State<StatefulWidget> createState() => _MedicalPrescriptionState();

}

class _MedicalPrescriptionState extends BaseMvvmListState<MedicalPrescriptionListViewModel,MedicalPrescriptionFragment>{
  @override
  Widget buildRootView(BuildContext context, Widget loadingContentWidget) {
    return loadingContentWidget;
  }

  @override
  Widget createItemWidget(int index) {
    var item = viewModel.listItems[index];
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Row(
          crossAxisAlignment: CrossAxisAlignment.end,
          children: [
            CommonText(item.customerName,textSize: 17,fontWeight: FontWeight.bold),
            SizedBox(width: 10,),
            CommonText(item.bedNo,textSize: 15),
            SizedBox().setWeight(1),
            CommonText('处方号：${item.prescriptionNo??""}',fontWeight: FontWeight.bold)
          ],
        ),

        SizedBox(height: 10,),
        Row(
          children: [
            CommonText('处方日期：${item.prescriptionDate??""}'),
            SizedBox().setWeight(1),
            CommonText('科别：${item.department??""}'),
          ],
        ),
        SizedBox(height: 10,),
        CommonText('就诊卡号：${item.treatmentCard??""}'),
        SizedBox(height: 10,),
        CommonText('临床诊断：${item.diagnosticContent??""}'),
        SizedBox(height: 10,),
        DottedLine(),
        SizedBox(height: 10,),
        Row(
          children: [
            CommonText('上传日期：${item.uploadDate??""}',textSize: 15,textColor: Colors.grey[700]!),
            SizedBox().setWeight(1),
            CommonText('医生：${item.doctor}',textSize: 15,textColor: Colors.grey[700]!)
          ],
        )
        
      ],
    ).onTap(() {
      Go().push(MedicalPrescriptionDetailPage(item:item));
    }).addToContainer(
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: 6.borderRadius
      ),
      padding: EdgeInsets.symmetric(horizontal: 10,vertical: 12)
    );
  }
  


  @override
  MedicalPrescriptionListViewModel createViewModel() {
    return MedicalPrescriptionListViewModel(context);
  }

  @override
  EdgeInsets get listPadding => EdgeInsets.symmetric(horizontal: 16,vertical: 12);

  @override
  Widget get separatorDivider => SizedBox(height: 12,);

}